package com.cyanite.playlv2api.parsers.json;

import com.cyanite.playlv2api.parsers.json.Parser;
import com.cyanite.playlv2api.types.PlayLv2Type;
import com.cyanite.playlv2api.types.Group;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;


public abstract class AbstractParser<T extends PlayLv2Type> implements Parser<T> {

    /** 
     * All derived parsers must implement parsing a JSONObject instance of themselves. 
     */
    public abstract T parse(JSONObject json) throws JSONException;
    
    /**
     * Only the GroupParser needs to implement this.
     */
    @SuppressWarnings("unchecked")
    public Group parse(JSONArray array) throws JSONException {
        throw new JSONException("Unexpected JSONArray parse type encountered.");
    }
}